<?	/*
	// File:	pureftpd.wcp.phps
	// Purpose:	PureFTPd user manipulation
	// Author:	Felix <webmaster@can-host.com>
	*/



// Handle user manipulation
if ($type == "user") {
	// Create User :: expect *
	if ($data['action'] == "create") {
		if ($data['type'] == "standard") {
			$pass = $cfg['basedir']."/server/data/tmp.pass";
			$fp = fopen($pass, "w+");
			$userid = posix_getpwnam($data['username']);
			fputs($fp, $data['password']. "\n" .$data['password']);
			fclose($fp);
			exec($cfg['prog']['pureftpd']." useradd ".$data['username']." -u ".$userid["uid"]." -g ".$userid["gid"]." -d ".$data['root']." -m < $pass\n");
		}
	}
	
	// Update User :: expect *
	if ($data['action'] == "update") {
		// update user
		if ($data['type'] == "standard") {
			$pass = $cfg['basedir']."/server/data/tmp.pass";
			$fp = fopen($pass, "w+");
			$userid = posix_getpwnam($data['username']);
			fputs($fp, $data['password']. "\n" .$data['password']);
			fclose($fp);
			exec($cfg['prog']['pureftpd']." passwd ".$data['username']." -m < $pass\n");
		}
	}
	
	// Suspend User :: expect username
	if ($data['action'] == "suspend") {
		// ******* anything here? **********
	}
	
	// Unsuspend User :: expect username
	if ($data['action'] == "unsuspend") {
		// ******* anything here? **********
	}
	
	// Remove User :: expect username
	if ($data['action'] == "remove") {
		// remove user
		if ($data['type'] == "standard")
			exec($cfg['prog']['pureftpd']." userdel ".$data['username']." -m");
	}
}
?>